<?php

// $Id$

require_once(TANGRA_MAIN_DIR.'interfaces/i_dynamic_viewable.class.php');

require_once(TANGRA_MAIN_DIR.'exceptions/tangra_module_exception.class.php');


class Tple_HTML_Gatherer implements I_Dynamic_Viewable {
	private $tpl_file;

	function __construct($tpl_file = '') {
		$this->set_tpl_file($tpl_file);
	}


	public function get_html(TPLE_Exports $exports) {
		$ret = '';

		$arr = $exports->get_pairs();

		$tple = New Tple();
		foreach($arr as $key => $value) {
			$tple->assign($key, $value);
		}

		if (file_exists($this->tpl_file)) {
			$ret = $tple->fetch($this->tpl_file);
		} else {
			throw new Tangra_Module_Exception('Can not find template file: '.$this->tpl_file);
		}

		return $ret;
	}


	public function set_tpl_file($tpl_file) {
		$this->tpl_file = $tpl_file;
	}


	public function query_tpl_file() {
		return $this->tpl_file;
	}
}





